let  fs=require('fs')


// 获取文件或文件夹的信息
// fs.stat(文件路径,callback) 
// fs.statSync(文件路径)


fs.stat("./1",(err,stats)=>{
    // console.log(err); //捕获错误
    // console.log(stats);//文件信息

    console.log(stats.isFile()); // 判断是否是文件
    console.log(stats.isDirectory()); // 判断是否是文件夹


    /* 
        null

        Stats {
        dev: 775157077,
        mode: 33206,
        nlink: 1,
        uid: 0,
        gid: 0,
        rdev: 0,
        blksize: 4096,
        ino: 3940649674154049,
        size: 0,
        blocks: 0,
        atimeMs: 1659427254232.5498,
        mtimeMs: 1659427192179.6375,
        ctimeMs: 1659427192179.6375,
        birthtimeMs: 1659427192179.6375,
        atime: 2022-08-02T08:00:54.233Z,
        mtime: 2022-08-02T07:59:52.180Z,
        ctime: 2022-08-02T07:59:52.180Z,
        birthtime: 2022-08-02T07:59:52.180Z
    } */
    /* 
        [Error: ENOENT: no such file or directory, stat 'C:\Users\Administrator\Desktop\软件学院20220411\day06nodejs\代码\5.文件相关操作\2.txt'] {
        errno: -4058,
        code: 'ENOENT',
        syscall: 'stat',
        path: 'C:\\Users\\Administrator\\Desktop\\软件学院20220411\\day06nodejs\\代码\\5.文件相关操作\\2.txt'
        }

        undefined
    */



})


let stats=fs.statSync("1.txt")
// console.log(stats,1111111111);
// console.log(stats.isDirectory(),111111111);
// console.log(stats.isFile(),2222222222);